Skip to content

Consider as const expressions as potentially context sensitive #62221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Aug 6, 2025

fixes #62220

@Copilot Copilot AI review requested due to automatic review settings August 6, 2025 22:02
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Aug 6, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 6, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes TypeScript issue #62220 by making as const expressions context sensitive during type inference. The change allows the TypeScript compiler to properly infer types when as const is used in function arguments that depend on intra-expression type relationships.

Key changes:

  • Modified the isContextSensitive function in the type checker to consider as const expressions as potentially context sensitive
  • Added comprehensive test cases demonstrating the improved type inference behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/compiler/checker.ts Core logic change to treat as const expressions as context sensitive when applied to context sensitive expressions
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts Test cases showing improved type inference with as const expressions
tests/baselines/reference/intraExpressionInferences.types Updated type baselines showing more precise type inference (100 vs number)
tests/baselines/reference/intraExpressionInferences.symbols Updated symbol baselines reflecting the new test cases
tests/baselines/reference/intraExpressionInferences.js Updated JavaScript output baselines
tests/baselines/reference/intraExpressionInferences.errors.txt Updated error baselines with new test content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

as const breaks intra expression inference
2 participants